import { S } from '../s';
import { IPSControlAction } from './ipscontrol-action';
import { IPSControlNavContext } from './ipscontrol-nav-context';
import { IPSControlNavParam } from './ipscontrol-nav-param';
import { IPSMDAjaxControl } from './ipsmdajax-control';
import { IPSMDControl2 } from './ipsmdcontrol2';
import { PSAjaxControlContainerImpl } from './psajax-control-container-impl';
import { IPSDEDataExport } from '../dataentity/dataexport/ipsdedata-export';
import { IPSDEDataImport } from '../dataentity/dataimport/ipsdedata-import';

export class PSMDAjaxControlContainerImpl
  extends PSAjaxControlContainerImpl
  implements IPSMDAjaxControl, IPSMDControl2
{
  get activeDataField(): string {
    return this.M.activeDataField;
  }

  protected createpscontrolaction: IPSControlAction;
  getCreatePSControlAction(): IPSControlAction | null {
    if (this.createpscontrolaction != null) return this.createpscontrolaction;
    const value = this.M.getCreatePSControlAction;
    if (value == null) {
      return;
    }
    this.createpscontrolaction =
      this.getPSControlHandler().findPSControlHandlerAction(value);
    return this.createpscontrolaction;
  }

  protected fetchpscontrolaction: IPSControlAction;
  getFetchPSControlAction(): IPSControlAction | null {
    if (this.fetchpscontrolaction != null) return this.fetchpscontrolaction;
    const value = this.M.getFetchPSControlAction;
    if (value == null) {
      return;
    }
    this.fetchpscontrolaction =
      this.getPSControlHandler().findPSControlHandlerAction(value);
    return this.fetchpscontrolaction;
  }

  protected getdraftfrompscontrolaction: IPSControlAction;
  getGetDraftFromPSControlAction(): IPSControlAction | null {
    if (this.getdraftfrompscontrolaction != null)
      return this.getdraftfrompscontrolaction;
    const value = this.M.getGetDraftFromPSControlAction;
    if (value == null) {
      return;
    }
    this.getdraftfrompscontrolaction =
      this.getPSControlHandler().findPSControlHandlerAction(value);
    return this.getdraftfrompscontrolaction;
  }

  protected getdraftpscontrolaction: IPSControlAction;
  getGetDraftPSControlAction(): IPSControlAction | null {
    if (this.getdraftpscontrolaction != null)
      return this.getdraftpscontrolaction;
    const value = this.M.getGetDraftPSControlAction;
    if (value == null) {
      return;
    }
    this.getdraftpscontrolaction =
      this.getPSControlHandler().findPSControlHandlerAction(value);
    return this.getdraftpscontrolaction;
  }

  protected getpscontrolaction: IPSControlAction;
  getGetPSControlAction(): IPSControlAction | null {
    if (this.getpscontrolaction != null) return this.getpscontrolaction;
    const value = this.M.getGetPSControlAction;
    if (value == null) {
      return;
    }
    this.getpscontrolaction =
      this.getPSControlHandler().findPSControlHandlerAction(value);
    return this.getpscontrolaction;
  }

  protected pscontrolnavcontexts: IPSControlNavContext[];
  getPSControlNavContexts(): IPSControlNavContext[] | null {
    return (
      this.pscontrolnavcontexts ||
      (this.pscontrolnavcontexts = this.fillChildListModel(
        this.M.getPSControlNavContexts,
        S._38c,
      ) as IPSControlNavContext[])
    );
  }

  findPSControlNavContext(objKey: any): IPSControlNavContext | null {
    return this.getPSModel5(
      S._38c,
      this.getPSControlNavContexts(),
      objKey,
    ) as IPSControlNavContext;
  }

  protected pscontrolnavparams: IPSControlNavParam[];
  getPSControlNavParams(): IPSControlNavParam[] | null {
    return (
      this.pscontrolnavparams ||
      (this.pscontrolnavparams = this.fillChildListModel(
        this.M.getPSControlNavParams,
        S._38b,
      ) as IPSControlNavParam[])
    );
  }

  findPSControlNavParam(objKey: any): IPSControlNavParam | null {
    return this.getPSModel5(
      S._38b,
      this.getPSControlNavParams(),
      objKey,
    ) as IPSControlNavParam;
  }

  protected psdedataexport: IPSDEDataExport;
  getPSDEDataExport(): IPSDEDataExport | null {
    if (this.psdedataexport != null) return this.psdedataexport;
    const value = this.M.getPSDEDataExport;
    if (value == null) {
      return;
    }
    this.psdedataexport =
      this.getPSAppDataEntity().findPSAppDEDataExport(value);
    return this.psdedataexport;
  }

  protected psdedataimport: IPSDEDataImport;
  getPSDEDataImport(): IPSDEDataImport | null {
    if (this.psdedataimport != null) return this.psdedataimport;
    const value = this.M.getPSDEDataImport;
    if (value == null) {
      return;
    }
    this.psdedataimport =
      this.getPSAppDataEntity().findPSAppDEDataImport(value);
    return this.psdedataimport;
  }

  protected removepscontrolaction: IPSControlAction;
  getRemovePSControlAction(): IPSControlAction | null {
    if (this.removepscontrolaction != null) return this.removepscontrolaction;
    const value = this.M.getRemovePSControlAction;
    if (value == null) {
      return;
    }
    this.removepscontrolaction =
      this.getPSControlHandler().findPSControlHandlerAction(value);
    return this.removepscontrolaction;
  }

  protected updatepscontrolaction: IPSControlAction;
  getUpdatePSControlAction(): IPSControlAction | null {
    if (this.updatepscontrolaction != null) return this.updatepscontrolaction;
    const value = this.M.getUpdatePSControlAction;
    if (value == null) {
      return;
    }
    this.updatepscontrolaction =
      this.getPSControlHandler().findPSControlHandlerAction(value);
    return this.updatepscontrolaction;
  }

  hasWFDataItems(): boolean {
    return this.M.hasWFDataItems;
  }

  get activeDataMode(): boolean {
    return this.M.activeDataMode != null ? this.M.activeDataMode : false;
  }

  get readOnly(): boolean {
    return this.M.readOnly != null ? this.M.readOnly : false;
  }
  get cls(): string {
    return 'PSMDAjaxControlContainerImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._244 || cls == S._245 || cls == S._246) return true;
    return super.instanceof(cls);
  }
}
